﻿using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using W.Warehouse.Api.Application.Command.WarehouseCommand;
using W.Warehouse.Api.Application.Command.WarehouseTypeCommand;
using W.Warehouse.Domain;
using W.Warehouse.Repository.Interface;

namespace W.Warehouse.Api.Controllers
{
    /// <summary>
    /// 仓库管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class WarehouseInfosController : ControllerBase
    {
        private readonly IMediator _mediator;
        public WarehouseInfosController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 添加仓库管理
        /// </summary>
        /// <param name="warehouseInfo"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> AddWarehouseInfo(WarehouseCreateCommand warehouseInfo)
        {
            return await _mediator.Send(warehouseInfo);
        }
        /// <summary>
        /// 删除仓库管理
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> DelectWarehouseInfo(WarehouseDelectCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 批量删除仓库管理
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> DelectRangeWarehouseInfo(WarehouseDelectRangeCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 修改仓库管理
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> UpdateWarehouseInfo(WarehouseUpdateCommand command)
        {
            return await _mediator.Send(command);
        }
    }
}
